package com.qfmy.mystation.ui.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.qfmy.mystation.bean.CategoryBean;
import com.qfmy.mystation.ui.fragment.ItemFragment;

import java.util.List;

public class WallpaperTabAdapter extends FragmentStateAdapter {
    private final List<CategoryBean> menu;
    private final int type;

    public WallpaperTabAdapter(@NonNull FragmentActivity fragmentActivity, List<CategoryBean> menu, int type) {
        super(fragmentActivity);
        this.menu = menu;
        this.type = type;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return ItemFragment.newInstance(menu.get(position).getName(), type);
    }

    @Override
    public int getItemCount() {
        return menu == null ? 0 : menu.size();
    }
}
